function randomArray(arr) {
  let length = arr.length,
    randomIndex = 0;
  while (length) {
    randomIndex = Math.floor(Math.random() * length--);
    [arr[length], arr[randomIndex]] = [arr[randomIndex], arr[length]];
  }
  return arr;
}

const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let res = randomArray(arr);
console.log(res);
